﻿//INNOVACALL FRAMEWORK MUST BE IN ALL VIEW JAVASCRIPT
$.fn.DocReady = function () {
	//Add call to execute when document is ready
	$.fn.PrepareLayoutMenus();
	$("#ddlSample").kendoDropDownList();
	$("#ddlSample").live("change", $.fn.GetItemDescription)
	$("#cmdOk").button();
	$.fn.TabifyCodeFiles();
}

$.fn.MainAjaxSuccess = function (a, b, c) {
	if (a.ScriptToExecute != null) {
		eval(a);
	}
}
//ErrMsg_Sample_SingleControl_DropDownList_CannotUpdate come from server side via DynamicScript
$.fn.GetItemDescription = function () {
	//Préparation des donnes
	var selectedItemId = $(this).val();
	var url = "/Sample_SingleControl_DropDownList/GetItemDescription/" + selectedItemId;

	$.ajax(
	{
		type: "POST",
		url: url,
		data: null,
		async: false,
		success: function (r) {
			if (r.success) {
				$(r.divToUpdate).css("border", "1px solid green");
			} else {
				$(r.divToUpdate).css("border", "1px solid red");
			}
			$(r.divToUpdate).html(r.htmlResult);
		},
		error: function (xhr, ajaxOptions, thrownError) {
			alert(ErrMsg_Sample_SingleControl_DropDownList_CannotUpdate);
		}
	});
}